
<style>
.pager_container {
	text-align: center;
	margin: 10px 10px 10px 10px;
}

.pager_container .pager_prev_disabled, .pager_container .pager_next_disabled, .pager_container .pager_lgthen_dis {
	color: silver;
	cursor: default;
}

.pager_container .pager_is_current {
	background-color: #3AB1FF;
	border-color: #3AB1FF;
	color: #fff;
	font-weight: 700;
	cursor: default;
}

.pager_container span {
	border: 1px solid #e8e8e8;
	color: #555;
	cursor: pointer;
	display: inline-block;
	font-size: 14px;
	line-height: 21px;
	margin: 0 2px;
	padding: 3px 10px;
	text-decoration: none;
}
</style>
<script type="text/javascript">
	function reloadPage(pager){
		var pageNo=0;//当前页码	
		var pageSize=0;//页面大小
		var pageCount=0;//总页面数目
		var itemCount=0;//元素数目
		if(typeof(pager) == "undefined"){
			<#if Session.pager??>
			// 从Session中取到对应的值
			pageNo=${Session.pager.pageNo!};
			if(pageNo==null){
				return;
			}
			pageSize=${Session.pager.pageSize!};
			pageCount=${Session.pager.pageCount!};
			itemCount=${Session.pager.itemCount!};
			</#if>
		}else{
			pageNo=pager.pageNo;
			if(pageNo==null){
				return;
			}
			pageSize=pager.pageSize;
			pageCount=pager.pageCount;
			itemCount=pager.itemCount;
		}
		
		// 计算显示的最小页、最大页
		var pageMin = pageNo - 5;
		var pageMax = pageNo + (pageSize - 6);

		// 修正最小页
		if (pageMin < 1) {
			pageMin = 1;
			pageMax = pageSize;
			if (pageMax > pageCount) {
				pageMax = pageCount;
			}
		}

		// 修正最大页
		if (pageMax > pageCount) {
			pageMax = pageCount;
			pageMin = pageMax - pageSize + 1;
			if (pageMin < 1) {
				pageMin = 1;
			}
		}

		var ulHtml="";
		if(pageNo<1){
			ulHtml+= '<span hidefocus="hidefocus" class="pager_prev pager_prev_disabled">首页</span>';
			ulHtml+= '<span hidefocus="hidefocus"  class="pager_next pager_prev_disabled">上一页</span>';
			ulHtml+= '<span hidefocus="hidefocus" class="pager_is_current">1</span>';
			ulHtml+= '<span hidefocus="hidefocus"  class="pager_next pager_prev_disabled">下一页</span>';
			ulHtml+= '<span hidefocus="hidefocus"  class="pager_next pager_prev_disabled">尾页</span>';
		}else{
			// 页面描述变量
			//var ulPageDescript = '第'+pageNo+'页,共'+pageCount+'页['+itemCount+'条记录],每页显示'+pageSize+'条';
			// 首页显示变量
			var ulPageFirst = '<span hidefocus="hidefocus" class="pager_prev"><a href="javascript:loc(1);">首页</a></span>';
			// 上一页显示变量
			var ulPagePre = '<span hidefocus="hidefocus" class="pager_prev"><a href="javascript:loc(' + (pageNo - 1) + ');">上一页</a></span>';
			// 下一页显示变量
			var ulPageNext = '<span hidefocus="hidefocus" class="pager_prev"><a href="javascript:loc(' + (pageNo + 1) + ');">下一页</a></span>';
			// 尾页显示变量
			var ulPageLast = '<span hidefocus="hidefocus" class="pager_prev"><a href="javascript:loc(' + pageCount + ');">尾页</a></span>';
			if (pageNo == 1) {// 如果当前页为首页，首页与上一页不可选择
				ulPageFirst = '<span hidefocus="hidefocus" class="pager_prev pager_prev_disabled">首页</span>';
				ulPagePre = '<span hidefocus="hidefocus" class="pager_prev pager_prev_disabled">上一页</span>';
			}
			if (pageNo == pageCount) {// 如果当前页为尾页，下一页与尾页不可选择
				ulPageNext = '<span hidefocus="hidefocus" class="pager_prev pager_prev_disabled">下一页</span>';
				ulPageLast = '<span hidefocus="hidefocus" class="pager_prev pager_prev_disabled">尾页</span>';
			}
			//ulHtml +='<ul class="pagination">';
			ulHtml += ulPageFirst;
			ulHtml += ulPagePre;
			// 循环从最小页输出到最大页
			for (var i = pageMin; i < pageMax + 1; i++) {
				if (i == pageNo) {
					// 输出当前页
					ulHtml += '<span hidefocus="hidefocus" class="pager_is_current">' + i + '</span>';
				} else {
					// 输出其它页
					ulHtml += '<span hidefocus="hidefocus" class="pager_not_current"><a href="javascript:loc(' + i + ');">' + i + '</a></span>';
				}
			}
			ulHtml += ulPageNext;
			ulHtml += ulPageLast;
		}
		$("#table_paginate").html(ulHtml);
	}
	
	function loc(pageNo) {
		var url = "${base}/resetPageAction.json";
		var entity = {
			pageNo: pageNo
		};
		var onloadFunc = function(result) {
			if (result.isSuccess == true) {
				reloadAllData();
			} else {
				alert(result.message);
			}
		};
		httpRequestPostJson(url, entity, false, onloadFunc);
	};
</script>

<div class="item_con_pager">
	<div class="pager_container" id="table_paginate"></div>
</div>
